
import time
import base64
import re
with open("flag_encode.txt","rb") as f:
    tmp=base64.b16decode(f.read().strip())

re64=rb'^[A-Za-z0-9/+=]+$'
re32=rb'^[A-Z2-7=]+$'
re16=rb'^[A-F0-9]+$'
while 1:
    t=tmp.decode("utf-8","ignore")
    if "{" in t:
        print(t)
        break
    elif re.fullmatch(re16,tmp):
        tmp = base64.b16decode(tmp)
    elif re.fullmatch(re32,tmp):
        tmp= base64.b32decode(tmp)
    elif re.fullmatch(re64,tmp):
        tmp = base64.b64decode(tmp)

